﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Prodma.DataAccess.Models.UserControlViewModels.DataPagerVm>" %>
<% int limitValue = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["dataPagerLimit"]); %>
<% int pageCount = ViewData.Model.TotalRowCount / limitValue; %>

<% if (ViewData.Model.TotalRowCount <= limitValue)
   {
       return;
   } %>

<% if (ViewData.Model.TotalRowCount % limitValue > 0)
   {
       pageCount++;
   } %>
   
   <% string url = "/" + ViewData.Model.View + "/index/?"; %>
   <% if (Request.QueryString["find"] == null) %>
   <% { %>
        <% if (ViewData.Model.Keys.Count != 0) %>
        <% { %>
             <% for (int i = 0; i < ViewData.Model.Keys.Count; i++) %>  
             <% { %>
                  <% url += ViewData.Model.Keys[i] + "=" + ViewData.Model.Values[i]; %>
                  <% if (i != ViewData.Model.Keys.Count - 1) %>
                  <%{ %>
                      <% url += "&"; %>
                  <%} %>
             <% } %>
             <a class="pageNumber" href='<%=url+0 %>'><div class="pageNumberBox">&lt;&lt;&lt</div></a>
             <% for (int j = 0; j < pageCount; j++) %>
             <% { %>
                  <a class="pageNumber" href='<%=url + j %>'>
                       <div class="pageNumberBox">
                        <%= j + 1%>
                       </div>
                   </a>
             <% } %>
        <% } %>
   <% } %>
   <% else %>
   <% { %>
        <% if (ViewData.Model.Keys.Count != 0) %>
        <% { %>
             <% for (int i = 0; i < ViewData.Model.Keys.Count; i++) %>  
             <% { %>
                  <% url += ViewData.Model.Keys[i] + "=" + ViewData.Model.Values[i]; %>
                  <% if (i != ViewData.Model.Keys.Count - 1) %>
                  <%{ %>
                      <% url += "&"; %>
                  <%} %>
             <% } %>
             <% for (int j = 0; j < pageCount; j++) %>
             <% { %>
                  <a class="pageNumber" href='<%=url + j + "&find=" + Request.QueryString["find"] %>'>
                       <div class="pageNumberBox">
                        <%= j + 1%>
                       </div>
                   </a>
             <% } %>
        <% } %>
        
   <% } %>
   <a class="pageNumber" href='<%=url + (pageCount-1) %>'><div class="pageNumberBox">>>></div></a>
   <div class="pageContainerHeader">
    Sayfa <%=Convert.ToInt32(Request.QueryString["page"]) + 1%> / <%=pageCount%>
   </div>